require('./PageYeWuHome.less');

import React,{Component} from 'react';
import Reflux from 'reflux';
import ReactMixin from 'react-mixin';
import Actions from './Actions'
import Store from './Store';
import StorageUtils from '../../../app/storage';
import 'weui';
import { Tab,TabBarItem,TabBar,Page,
  Panel,
  PanelHeader,
  PanelBody,
  PanelFooter,
  MediaBox,
  MediaBoxHeader,
  MediaBoxBody,
  MediaBoxTitle,
  MediaBoxDescription,
  MediaBoxInfo,
  MediaBoxInfoMeta,
  Cells,
  Cell,
  CellHeader,
  CellBody,
  CellFooter,
  Flex,
  FlexItem,
  Grids
} from  'react-weui/build/packages'
import IconButton from '../../../assets/img/icon_nav_button.png';
import IconMsg from '../../../assets/img/icon_nav_msg.png';
import IconArticle from '../../../assets/img/icon_nav_article.png';


import { Control,HashRouter,Route } from 'react-keeper'
import Utils from '../../../utils/index'



class YeWuHome extends Component {
  constructor(props) {
    super(props);
    this.handleRouter = this.handleRouter.bind(this);

    this.myscane = this.myscane.bind(this);

  }

  myscane(){
    wx.scanQRCode({
      needResult: 1,
      desc: 'scanQRCode desc',
      scanType: ["qrCode"],
      success: function (res) {
      Control.go('/myyewu/qrhome',res);
      }
    });
  }

  handleRouter(v) {

    console.info(v);
    switch(v.text){
      case "扫码登录" :  this.myscane(); break;

      case "整改回复" :  Control.go(v.router,v.lx) ; break;

      case "复工申请" :  Control.go(v.router,v.lx); break;

      default :  Control.go(v.router); break;
    }

  }

  render() {
    return (
      <div className="page userlogin">
        <Panel className="head-panel">
          <PanelHeader>
            <div className="title-bg"/>
            业务办理
          </PanelHeader>
          <PanelBody>
            <Flex>
              {
                this.state.ywhome.ywblo.map((v, k)=> {
                  return (
                    <FlexItem onClick={this.handleRouter.bind(this,v)}>
                      <div className="grid-ywbl">
                        <p style={{paddingTop:'15px'}}><img height="30" width="30" src={v.icon}/></p>
                        <p className="grid-title-text">{v.text}</p>
                      </div>
                    </FlexItem>)
                })
              }

            </Flex>
            <Flex>
              {
                this.state.ywhome.ywblt.map((v, k)=> {
                  return (
                    <FlexItem onClick={this.handleRouter.bind(this,v)}>
                      <div className="grid-ywbl">
                        <p style={{paddingTop:'15px'}}><img height="30" width="30" src={v.icon}/></p>
                        <p className="grid-title-text">{v.text}</p>
                      </div>
                    </FlexItem>)
                })
              }
{/*              <FlexItem>
                <div className="grid-ywbl">
                  <p style={{paddingTop:'15px'}}></p>
                  <p className="grid-title-text"></p>
                </div>
              </FlexItem>*/}
            </Flex>
          </PanelBody>
        </Panel>

  {/*      <Panel className="head-panel">
          <PanelHeader>
            <div className="title-bg"/>
            日志填写
          </PanelHeader>
          <PanelBody>
            <Flex>
              {
                this.state.home.rztb.map((v, k)=> {
                  return (
                    <FlexItem onClick={this.handleRouter.bind(this,v)}>
                      <div className="grid-ywbl">
                        <p style={{paddingTop:'15px'}}><img height="30" width="30" src={v.icon}/></p>
                        <p className="grid-title-text">{v.text}</p>
                      </div>
                    </FlexItem>)
                })
              }
              <FlexItem>
                <div className="grid-ywbl">
                  <p style={{paddingTop:'15px'}}></p>
                  <p className="grid-title-text"></p>
                </div>
              </FlexItem>
            </Flex>
          </PanelBody>
        </Panel>*/}

      </div>


    )
  }


  componentWillMount() {
    console.log(Utils.GetQueryString(window.location.search, 'code'));
    Actions.initMode();
  }

  componentDidMount() {

    Actions.initUser();

  }

  componentWillReceiveProps(nextProps) {

  }

  shouldComponentUpdate(nextProps, nextState) {

    return true;
  }

  componentWillUpdate(nextProps, nextState) {

  }


  componentDidUpdate(prevProps, prevState) {

  }

  componentWillUnmount() {
  }
}

ReactMixin.onClass(YeWuHome, Reflux.connect(Store, 'ywhome'));

export default YeWuHome;
